package com.hang.controller;

import com.hang.common.Result;
import com.hang.model.dto.response.DictDTO;
import com.hang.service.IDictService;
import com.hang.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "字典管理接口")
@RequestMapping("dict")
@RestController
public class DictController {
    @Resource
    private IUserService userService;

    @Resource
    private IDictService dictService;

    @ApiOperation(value = "获取所有项目管理员和项目经理")
    @GetMapping("getAllManager")
    public Result<List<DictDTO>> getAllManager(){
        List<DictDTO> dictDTOList = userService.getAllManagers();
        return Result.ok(dictDTOList);
    }

    @ApiOperation(value = "获取所有字典集合")
    @GetMapping("getAllDict")
    public Result<List<DictDTO>> getAllDict(){
        List<DictDTO> dictDTOList = dictService.getAllDict();
        return Result.ok(dictDTOList);
    }

    @ApiOperation(value = "获取指定字典的下拉选择")
    @GetMapping("getDictByValue")
    public Result<List<DictDTO>> getDictByValue(@RequestParam("value") String value){
        List<DictDTO> dictDTOList = dictService.getDictByValue(value);
        return Result.ok(dictDTOList);
    }
}
